home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / gfft.lha / gfft-2.03 / source / gfft-2.03-source.lha / format.h < prev    next >
C/C++ Source or Header  |  1996-01-02  |  5KB  |  135 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        format.h
  13.  * Purpose:     definitions for parsing formatted files
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     17-October-1993 CPP; Created.
  16.  * Comment:     Whenever possible, I've borrowed from IFF-85 'cause its PD.
  17.  *              Some of the more recent C= iff codes ain't.
  18.  *              Thanks also to David Champion's OPLAY which helped me get
  19.  *                started on this.
  20.  */
  21.  
  22. #ifndef FORMAT_H
  23. #define FORMAT_H
  24.  
  25. #include "gfft.h"  /* Must include now if not already included */
  26.  
  27. #define ID ULONG
  28.  
  29. /* This macro rounds up to an even number. */
  30. #define WordAlign(size)   ((size+1)&~1)
  31.  
  32. /*
  33.  * As it may be machine dependent, 
  34.  * MakeID is defined in [amiga|unix|msdos]def.h
  35.  */
  36.  
  37. struct ChunkHeader {
  38.   ID ckID;
  39.   ULONG ckSize;
  40. };
  41.  
  42. /*
  43.  * 8SVX files
  44.  */
  45.  
  46. #ifdef ID_FORM
  47. #undef ID_FORM
  48. #endif
  49.  
  50. #define ID_FORM  MakeID('F','O','R','M') /* required chunk */
  51. #define ID_8SVX  MakeID('8','S','V','X') /* required chunk */
  52. #define ID_VHDR  MakeID('V','H','D','R') /* required chunk */
  53. #define ID_BODY  MakeID('B','O','D','Y') /* required chunk */
  54.  
  55. struct VHDR {
  56.   ULONG    oneShotHiSamples;  /* # samples in the high octave 1-shot part */
  57.   ULONG    repeatHiSamples;   /* # samples in the high octave repeat part */
  58.   ULONG    samplesPerHiCycle; /* # samples/cycle in high octave, else 0 */
  59.   UWORD    samplesPerSec;    /* data sampling rate */
  60.   UBYTE    ctOctave;    /* # of octaves of waveforms */
  61.   UBYTE    sCompression;    /* data compression technique used */
  62.   long volume;            /* playback nominal volume from 0 to Unity */
  63. };
  64.  
  65. /*
  66.  * AIFF and AIFC
  67.  */
  68.  
  69. #define ID_AIFF  MakeID('A','I','F','F')
  70. #define ID_AIFC  MakeID('A','I','F','C')
  71. #define ID_COMM  MakeID('C','O','M','M')
  72. #define ID_SSND  MakeID('S','S','N','D')
  73. #define ID_COMT  MakeID('C','O','M','T')
  74. #define ID_NONE  MakeID('N','O','N','E')
  75.  
  76. struct CommAiff {
  77.  UWORD numChannels;
  78.  ULONG numSampleFrames;
  79.  UWORD sampleSize;
  80.  UBYTE sampleRate[10];  /* typed as "Extended" */
  81. };
  82.  
  83. struct CommAifc {
  84.  UWORD numChannels;
  85.  ULONG numSampleFrames;
  86.  UWORD sampleSize;
  87.  UBYTE sampleRate[10];  /* typed as "Extended" */
  88.  ID compressionType;
  89.  /* A variable length string here, which we don't care about yet */
  90. };
  91.  
  92. struct SoundDataChunkInfo {
  93.     ULONG    offset;
  94.     ULONG    blockSize;
  95.     /* Actual data may begin here (check offset) */
  96. };
  97.  
  98. /*
  99.  * AVR (Audio Visual Research)
  100.  */
  101. #define ID_AVR   MakeID('2','B','I','T')
  102.  
  103. struct AVRH {            /* Assumes ID_AVR has already been read */
  104.     char name[8];        /* null-padded sample name */
  105.     short mono;          /* 0 = mono, 0xffff = stereo */
  106.     short rez;           /* 8 = 8 bit, 16 = 16 bit */
  107.     short sign;          /* 0 = unsigned, 0xffff = signed */
  108.     short loop;          /* 0 = no loop, 0xffff = looping sample */
  109.     short midi;          /* 0xffff = no MIDI note assigned,
  110.                             0xffXX = single key note assignment
  111.                             0xLLHH = key split, low/hi note */
  112.     long rate;           /* sample frequency in hertz */
  113.     long size;           /* sample length in bytes or words (see rez) */
  114.     long lbeg;           /* offset to start of loop in bytes or words.
  115.                             set to zero if unused. */
  116.     long lend;           /* offset to end of loop in bytes or words.
  117.                             set to sample length if unused. */
  118.     short res1;          /* Reserved, MIDI keyboard split */
  119.     short res2;          /* Reserved, sample compression */
  120.     short res3;          /* Reserved */
  121.     char ext[20];        /* Additional filename space, used
  122.                             if (name[7] != 0) */
  123.     char user[64];       /* User defined. Typically ASCII message. */
  124. };
  125.  
  126. /*
  127.  * Other format ID's (not yet fully supported, but recognized)
  128.  */
  129.  
  130. #define ID_RIFF  MakeID('R','I','F','F')
  131. #define ID_VOCH  MakeID('C','r','e','a')
  132.  
  133.  
  134. #endif /* ifndef FORMAT_H */
  135.